package com.zte.claa.inficombo.csa.app.util;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;

/**
 * 获取Sring管理的实例,用于非Spring管理的对象访问Spring内部的对象
 * @author 0283000138
 *
 */
public class SpringBeans {

	private static ApplicationContext applicationContext;
	
	public static void setApplicationContext(ApplicationContext context) throws BeansException {
		applicationContext = context;
	}

	public static Object getBean(String name) {
		return applicationContext.getBean(name);
	}

	public static <T> T getBean(Class<T> clazz){
        return applicationContext.getBean(clazz);
    }
}
